<%-- 
    Document   : FRoute
    Created on : 01/05/2010, 12:30:02
    Author     : TIAGO
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="br.terminalrodoviario.Route"%>
<%@page import="br.terminalrodoviario.City"%>
<%@page import="br.terminalrodoviario.RouteType"%>
<%@page import="java.util.*, java.text.*" %>
<jsp:useBean class="br.terminalrodoviario.Route" id="Route" scope="page"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%
            String id = request.getParameter("id");
            if (id != null) {
                Route = new Route().selectById("Select r from Route r where r.id = " + id);
            }
%>
<html>
    <head>
        <title>Guia Terminal Rodoviário</title>
        <script type="text/javascript" src="../../add/js/cities.js"></script>
        <style type="text/css">
            @import url("../../add/css/company.css");
            @import url("../../add/css/rodape.css");
        </style>
    </head>
    <body>
        <div class="geral">
            <table>
                <tr>
                    <td>
                        <div id="cabecalho">
                        </div>
                    </td>
                </tr>
            </table>
            <table id="menuAdmin" width="762">
                <tr >
                    <td align="center">
                        <ul class="menuRota" >
                            <li class="current"><a href="../Manager/MRoute.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuSolicitacao" >
                            <li><a href="../Manager/MSolicitation.jsp" /></li>
                        </ul>
                    </td>
                </tr>
            </table>

            <div style="float:left">
                <br/>
                <b><a href="../index.jsp">Início</a> -> <a href="../Manager/MRoute.jsp">Rotas</a> -> <a href="FRoute.jsp">Cadastrar Rota</a></b>
                <br/><br/>
            </div>
            <div align="right" style="font-family:calibri; font-size:11px; font-style:inherit">
                <br/>Bem-vindo <b><%=request.getSession().getAttribute("username")%></b>,<br/>
                você está logado desde <%=request.getSession().getAttribute("date_session")%>h. ( <a href="../logout.jsp"><b>Logout</b></a> )<br/><br/>
            </div>

            <table  id="subTitulo">
                <tr>
                    <td id="icone">
                        &nbsp;&nbsp;&nbsp;&nbsp;<img align="center" src="../../add/images/icones/route.png" alt="Rotas" title="Rotas"/>
                    </td>
                    <td>
                        Rotas
                    </td>
                </tr>
            </table>
            <br>

            <form action="../RouteServlet?acao=gravar&id=<%=request.getParameter("id")%>" method="post">
                <table>
                    <tr>
                        <td class="label_bg" style="width:150px;">&nbsp;&nbsp;Prefixo:</td>
                        <td>&nbsp;&nbsp;<input type="text" name="txtPrefix" value="<%=Route.getPrefix() == null ? "" : Route.getPrefix()%>"></td>
                    </tr>
                    <tr>
                        <td class="label">&nbsp;&nbsp;Tipo:</td>
                        <td>&nbsp;
                            <select class="calibri" name="cboRouteType" style="width:250px; height:22px;">
                                <%
                                            for (RouteType r : new RouteType().select("select r from RouteType r order by r.name asc")) {
                                %>
                                <option value="<%=r.getId()%>"  <%=(Route.getRouteType() != null && Route.getRouteType().getId() == r.getId() ? "selected='true'" : "")%>><%=r.getName()%></option>
                                <%
                                            }
                                %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="label_bg" style="width:150px;">&nbsp;&nbsp;De:</td>
                        <td>&nbsp;
                            <select class="calibri" name="cboStateFrom" style="width:150px; height:22px;" onchange="javascript:findCities(this.options[this.selectedIndex].value,'../../StateCityServlet','cboFrom');">
                                <option value="AC" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("AC") ? "selected='true'" : ""%>>Acre</option>
                                <option value="AL" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("AL") ? "selected='true'" : ""%>>Alagoas</option>
                                <option value="AM" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("AM") ? "selected='true'" : ""%>>Amazonas</option>
                                <option value="AP" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("AP") ? "selected='true'" : ""%>>Amapá</option>
                                <option value="BA" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("BA") ? "selected='true'" : ""%>>Bahia</option>
                                <option value="CE" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("CE") ? "selected='true'" : ""%>>Ceará</option>
                                <option value="DF" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("DF") ? "selected='true'" : ""%>>Distrito Federal</option>
                                <option value="ES" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("ES") ? "selected='true'" : ""%>>Espírito Santo</option>
                                <option value="GO" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("GO") ? "selected='true'" : ""%>>Goiás</option>
                                <option value="MA" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("MA") ? "selected='true'" : ""%>>Maranhão</option>
                                <option value="MT" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("MT") ? "selected='true'" : ""%>>Mato Grosso</option>
                                <option value="MS" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("MS") ? "selected='true'" : ""%>>Mato Grosso do Sul</option>
                                <option value="MG" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("MG") ? "selected='true'" : ""%>>Minas Gerais</option>
                                <option value="PA" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("PA") ? "selected='true'" : ""%>>Pará</option>
                                <option value="PB" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("PB") ? "selected='true'" : ""%>>Paraíba</option>
                                <option value="PR" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("PR") ? "selected='true'" : ""%>>Paraná</option>
                                <option value="PE" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("PE") ? "selected='true'" : ""%>>Pernambuco</option>
                                <option value="PI" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("PI") ? "selected='true'" : ""%>>Piauí</option>
                                <option value="RJ" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("RJ") ? "selected='true'" : ""%>>Rio de Janeiro</option>
                                <option value="RN" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("RN") ? "selected='true'" : ""%>>Rio Grande do Norte</option>
                                <option value="RO" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("RO") ? "selected='true'" : ""%>>Rondônia</option>
                                <option value="RS" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("RS") ? "selected='true'" : ""%>>Rio Grande do Sul</option>
                                <option value="RR" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("RR") ? "selected='true'" : ""%>>Roraima</option>
                                <option value="SC" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("SC") ? "selected='true'" : ""%>>Santa Catarina</option>
                                <option value="SE" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("SE") ? "selected='true'" : ""%>>Sergipe</option>
                                <option value="SP" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("SP") ? "selected='true'" : ""%>>São Paulo</option>
                                <option value="TO" <%=Route.getFrom() != null && Route.getFrom().getState() != null && Route.getFrom().getState().equals("TO") ? "selected='true'" : ""%>>Tocantins</option>
                            </select>
                            <select class="calibri" name="cboFrom" id="cboFrom" style="width:250px; height:22px;">
                                <%
                                            for (City c : new City().select("select c from City c where c.removed = 0 and state = '" + (Route.getFrom() != null ? Route.getFrom().getState() : "AC") + "' or c.id = " + (Route.getFrom() != null ? Route.getFrom().getId() : 0) + "  order by c.state asc,c.name asc")) {
                                %>
                                <option value="<%=c.getId()%>"  <%=(Route.getFrom() != null && Route.getFrom().getId() == c.getId() ? "selected='true'" : "")%>><%=c.getName()%></option>
                                <%
                                            }
                                %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">&nbsp;&nbsp;Para:</td>
                        <td>&nbsp;
                            <select class="calibri" name="cboStateTo" style="width:150px; height:22px;" onchange="javascript:findCities(this.options[this.selectedIndex].value,'../../StateCityServlet','cboTo');">
                                <option value="AC" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("AC") ? "selected='true'" : ""%>>Acre</option>
                                <option value="AL" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("AL") ? "selected='true'" : ""%>>Alagoas</option>
                                <option value="AM" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("AM") ? "selected='true'" : ""%>>Amazonas</option>
                                <option value="AP" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("AP") ? "selected='true'" : ""%>>Amapá</option>
                                <option value="BA" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("BA") ? "selected='true'" : ""%>>Bahia</option>
                                <option value="CE" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("CE") ? "selected='true'" : ""%>>Ceará</option>
                                <option value="DF" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("DF") ? "selected='true'" : ""%>>Distrito Federal</option>
                                <option value="ES" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("ES") ? "selected='true'" : ""%>>Espírito Santo</option>
                                <option value="GO" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("GO") ? "selected='true'" : ""%>>Goiás</option>
                                <option value="MA" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("MA") ? "selected='true'" : ""%>>Maranhão</option>
                                <option value="MT" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("MT") ? "selected='true'" : ""%>>Mato Grosso</option>
                                <option value="MS" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("MS") ? "selected='true'" : ""%>>Mato Grosso do Sul</option>
                                <option value="MG" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("MG") ? "selected='true'" : ""%>>Minas Gerais</option>
                                <option value="PA" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("PA") ? "selected='true'" : ""%>>Pará</option>
                                <option value="PB" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("PB") ? "selected='true'" : ""%>>Paraíba</option>
                                <option value="PR" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("PR") ? "selected='true'" : ""%>>Paraná</option>
                                <option value="PE" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("PE") ? "selected='true'" : ""%>>Pernambuco</option>
                                <option value="PI" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("PI") ? "selected='true'" : ""%>>Piauí</option>
                                <option value="RJ" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("RJ") ? "selected='true'" : ""%>>Rio de Janeiro</option>
                                <option value="RN" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("RN") ? "selected='true'" : ""%>>Rio Grande do Norte</option>
                                <option value="RO" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("RO") ? "selected='true'" : ""%>>Rondônia</option>
                                <option value="RS" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("RS") ? "selected='true'" : ""%>>Rio Grande do Sul</option>
                                <option value="RR" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("RR") ? "selected='true'" : ""%>>Roraima</option>
                                <option value="SC" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("SC") ? "selected='true'" : ""%>>Santa Catarina</option>
                                <option value="SE" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("SE") ? "selected='true'" : ""%>>Sergipe</option>
                                <option value="SP" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("SP") ? "selected='true'" : ""%>>São Paulo</option>
                                <option value="TO" <%=Route.getTo() != null && Route.getTo().getState() != null && Route.getTo().getState().equals("TO") ? "selected='true'" : ""%>>Tocantins</option>
                            </select>
                            <select class="calibri" name="cboTo" id="cboTo" style="width:250px; height:22px;">
                                <%
                                            for (City c : new City().select("select c from City c where c.removed = 0 and state = '" + (Route.getTo() != null ? Route.getTo().getState() : "AC") + "' or c.id = " + (Route.getTo() != null ? Route.getTo().getId() : 0) + "  order by c.state asc,c.name asc")) {
                                %>
                                <option value="<%=c.getId()%>"  <%=(Route.getTo() != null && Route.getTo().getId() == c.getId() ? "selected='true'" : "")%>><%=c.getName()%></option>
                                <%
                                            }
                                %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" colspan="2"><input type="submit" align="right" value="Gravar" name="acao"></td>
                    </tr>
                </table>
            </form>
            <br/>
            <table id="rodape" style="background-image:url(../../add/images/rodape.png);">
                <tr>
                </tr>
            </table>
            <table id="btRodape" style="text-decoration: none;" >
                 <tr>
                    <td align="center" width="80px">
                        <ul class="btYoutube">
                            <li><a title="Youtube" href="http://www.youtube.com" /></li>
                        </ul>
                    </td >
                    <td align="center" width="80px">
                        <ul class="btOrkut">
                            <li><a title="Orkut" href="http://www.orkut.com" /></li>
                        </ul>
                    </td>
                    <td align="center" width="205px">
                        <ul class="btTwitter">
                            <li><a title="Twitter" href="http://twitter.com" /></li>
                        </ul>
                    </td>
                    <td align="center">
                        <a title="Trabalhe Conosco" class="text" href="../../Carrer.jsp" >Trabalhe Conosco</a>
                    </td>
                    <td align="center"  width="">
                        <a title="Mapa do Site" class="text" href="../../SiteMap.jsp">Mapa do Site</a>
                    </td>
                    <td align="center" width="">
                        <a title="Contatos" class="text" href="../../Contact.jsp">Contatos</a>
                    </td>
                </tr>
            </table>
        </div>
    </body>
</html>
